<?php
header('Content-Type: text/html; charset=utf-8');

$statusStr = [
    "0" => "✅ 发送成功 - 短信平台",
    "-1" => "❌ 参数不全",
    "-2" => "⚠️ 服务器不支持CURL",
    "30" => "🔒 密码错误",
    "40" => "❌ 账号不存在",
    "41" => "⚠️ 余额不足",
    "42" => "⏳ 账户已过期",
    "43" => "🌐 IP限制",
    "50" => "🚫 含敏感词"
];

$user = "账号";
$pass = md5("密码");
$smsapi = "https://api.smsbao.com/";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $phone = trim($_POST["phone"]);
    $content = trim($_POST["content"]);

    // 发送请求
    $sendurl = $smsapi . "sms?u=" . $user . "&p=" . $pass . "&m=" . $phone . "&c=" . urlencode($content);
    $result = file_get_contents($sendurl);

    // 处理结果
    $color = '#2196F3';
    $icon = 'info';
    if ($result == 0) {
        $color = '#4CAF50';
        $icon = 'check_circle';
    } elseif (in_array($result, ['30','40','41','50'])) {
        $color = '#f44336';
        $icon = 'error';
    }

    echo <<<HTML
    <!DOCTYPE html>
    <html>
    <head>
        <title>发送结果</title>
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
        <style>
            body { 
                background: #f5f5f5; 
                display: flex; 
                justify-content: center; 
                align-items: center; 
                min-height: 100vh;
                margin: 0;
            }
            .result-card {
                background: white;
                padding: 2rem;
                border-radius: 16px;
                box-shadow: 0 4px 12px rgba(0,0,0,0.1);
                text-align: center;
                max-width: 400px;
                width: 90%;
            }
            .result-icon {
                font-size: 4rem;
                color: $color;
                margin-bottom: 1rem;
            }
        </style>
    </head>
    <body>
        <div class="result-card">
            <i class="material-icons result-icon">$icon</i>
            <h2>{$statusStr[$result]}</h2>
            <p>2秒后自动返回...</p>
        </div>
        <script>
            setTimeout(() => window.location.href = 'index.html', 2000);
        </script>
    </body>
    </html>
HTML;
}
?>